<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<script type="text/javascript" src="../js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
function deleteIt(id,name){
	if(confirm("确认删除"+name+"？")){
		$.ajax({
			type:"post",// 指定是post还是get
			data:"method=deleteStudent"+"&id="+id,//发送到服务器的数据 
			//data:"aa={name:'"+username+"',pass:'"+userpass+"'}",
			url:"servlet",//发送请求的地址
			dataType:"text",
			error:function(err){//如果确定能正确运行,可不写
				alert("错误");
			},
			success:ajaxSendCallBack1
		})	
	}
}
function ajaxSendCallBack1(data){
	location.reload();
}
function initPwd(id){
	$.ajax({
		type:"post",
		data:"method=initPwd&id="+id,
		url:"servlet",
		dataType:"text",
		success:successCallBack
	})
}
function successCallBack(data){
	alert("已将密码重置为‘000000’");
}
</script>
</head>
<body>

<table>
	<tr>
		<td>序号</td>
		<td>电话</td>
		<td>姓名</td>
		<td>身份证号</td>
		<td>地址</td>
		<td>驾考类型</td>
		<td colspan="3">操作</td>
	</tr>
	<c:forEach items="${list }" var="user" varStatus="status">
		<tr  <c:if test="${status.index%2==0 }">style="background-color:orange;"</c:if> >
			<td>${user.id }</td>
			<td>${user.phoneNumber }</td>
			<td>${user.name }</td>
			<td>${user.ipid }</td>
			<td>${user.address }</td>
			<td>${user.abcType }</td>
			<td><a href="#" onclick="deleteIt(${user.id},'${user.name}')">删除</a></td>
			<td><a href="servlet?method=updateIt&id=${user.id}">修改</a></td>
			<td><a href="#" onclick="initPwd(${user.id})">重置密码</a></td>
		</tr>
	</c:forEach>

</table>
 <div>
        第${page.pageno}/${page.totalpage}页 &nbsp;&nbsp;
        <a href="servlet?method=allUser&pageNo=1">首页</a>
        <c:choose>
          <c:when test="${page.pageno gt 1}">
            <a href="servlet?method=allUser&pageNo=${page.pageno-1 }">上一页</a>
          </c:when>
          <c:otherwise>
            <a href="javascript:alert('当前已经是第一页');">上一页</a>
          </c:otherwise>
        </c:choose>
        <c:choose>
          <c:when test="${page.pageno lt page.totalpage}">
            <a href="servlet?method=allUser&pageNo=${page.pageno+1 }">下一页</a>
          </c:when>
          <c:otherwise>
            <a href="javascript:alert('当前已经是最后一页');">下一页</a>
          </c:otherwise>
        </c:choose>
        
        <a href="servlet?method=allUser&pageNo=${page.totalpage}">末页</a>
        &nbsp;&nbsp;
        共${page.totalcount}条
</div>

</body>
</html>